//
//  CustomView2.m
//  SelfDrivingTravelling-IOS
//
//  Created by Teplot_01 on 16/8/1.
//  Copyright © 2016年 Teplot_01. All rights reserved.
//

#import "CustomView2.h"
#import "AppDelegate.h"
@implementation CustomView2
{
    UILabel *renshuLb;
    UITextField *renshuTF;
    UILabel *huodongLb;
    UITextField *huodongTF;
    UITextView *messageTV;
    UILabel *chefeigujiLb;
}
//在initWithFrame:方法中添加子控件
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        // 注意：该处不要给子控件设置frame与数据，可以在这里初始化子控件的属性
        renshuLb = [[UILabel alloc]init];
        renshuLb.text = @"选择人数:";
        renshuLb.font = [UIFont systemFontOfSize:13];
        [self addSubview:renshuLb];
        
        renshuTF = [[UITextField alloc]init];
        renshuTF.layer.borderWidth = 1;
        renshuTF.layer.borderColor = blackLineColore.CGColor;
        [self addSubview:renshuTF];
        
        huodongLb = [[UILabel alloc]init];
        huodongLb.text = @"选择活动:";
        huodongLb.font = [UIFont systemFontOfSize:13];
        [self addSubview:huodongLb];
        
        huodongTF = [[UITextField alloc]init];
        huodongTF.layer.borderWidth = 1;
        huodongTF.layer.borderColor = blackLineColore.CGColor;
        [self addSubview:huodongTF];
        
        messageTV = [[UITextView alloc]init];
        messageTV.layer.borderWidth = 1;
        messageTV.layer.borderColor = blackLineColore.CGColor;
        [self addSubview:messageTV];
        
        chefeigujiLb = [[UILabel alloc]init];
        chefeigujiLb.text = @"车费预估：880";
        chefeigujiLb.textAlignment = NSTextAlignmentCenter;
        chefeigujiLb.textColor = orangeTextColor;
        chefeigujiLb.font = [UIFont systemFontOfSize:12];
        [self addSubview:chefeigujiLb];
        
        self.jiagejieshaoBtn = [[UIButton alloc]init];
        [self.jiagejieshaoBtn setTitle:@"<拼车价格计算说明>" forState:UIControlStateNormal];
        [self.jiagejieshaoBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        self.jiagejieshaoBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.jiagejieshaoBtn];
        
        self.chengkePincheBtn = [[UIButton alloc]init];
        self.chengkePincheBtn.layer.borderWidth = 1;
        self.chengkePincheBtn.layer.cornerRadius = 5;
        self.chengkePincheBtn.layer.borderColor = Theme_Color.CGColor;
        [self.chengkePincheBtn setTitle:@"一键拼车" forState:UIControlStateNormal];
        [self.chengkePincheBtn setTitleColor:Theme_Color forState:UIControlStateNormal];
        [self addSubview:self.chengkePincheBtn];
        
        UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Action:)];
        [self addGestureRecognizer:singleTap];
    }
    return self;
}

//在`layoutSubviews`方法中设置子控件的`frame`（在该方法中一定要调用`[super layoutSubviews]`方法）
- (void)layoutSubviews{
    [super layoutSubviews];
    
    //约束
    [renshuLb mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(30),
        make.left.mas_equalTo(self.mas_left).offset(50),
        make.width.mas_equalTo(60),
        make.height.mas_equalTo(15);
    }];
    
    [renshuTF mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(26),
        make.left.mas_equalTo(renshuLb.mas_right).offset(28),
        make.right.mas_equalTo(self.mas_right).offset(-50),
        make.height.mas_equalTo(30);
    }];
    
    [huodongLb mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(renshuTF.mas_bottom).offset(25),
        make.left.mas_equalTo(self.mas_left).offset(50),
        make.width.mas_equalTo(60),
        make.height.mas_equalTo(15);
    }];
    
    [huodongTF mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(renshuTF.mas_bottom).offset(18),
        make.left.mas_equalTo(huodongLb.mas_right).offset(28),
        make.right.mas_equalTo(self.mas_right).offset(-50),
        make.height.mas_equalTo(30);
    }];
    
    [messageTV mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(huodongTF.mas_bottom).offset(20),
        make.left.mas_equalTo(self.mas_left).offset(50),
        make.right.mas_equalTo(self.mas_right).offset(-50),
        make.height.mas_equalTo(65);
    }];
    
    [chefeigujiLb mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(messageTV.mas_bottom).offset(10),
        make.left.mas_equalTo(self.mas_left).offset(110),
        make.right.mas_equalTo(self.mas_right).offset(-110),
        make.height.mas_equalTo(33);
    }];
    
    [self.jiagejieshaoBtn mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(chefeigujiLb.mas_bottom).offset(10),
        make.left.mas_equalTo(self.mas_left).offset(100),
        make.right.mas_equalTo(self.mas_right).offset(-100),
        make.height.mas_equalTo(33);
    }];
    
    [self.chengkePincheBtn mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.jiagejieshaoBtn.mas_bottom).offset(10),
        make.left.mas_equalTo(self.mas_left).offset(100),
        make.right.mas_equalTo(self.mas_right).offset(-100),
        make.height.mas_equalTo(33);
    }];
}
- (void)jiageBtnAction{
    
}
- (void)Action:(id)sender{
    [self endEditing:YES];
}


@end
